﻿<UserControl x:Class="Holdem.Core.Controls.HoldemKickerSelector"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:kickerlb="clr-namespace:Holdem.Core.Controls" 
             xmlns:system="clr-namespace:System;assembly=mscorlib"
             mc:Ignorable="d"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    d:DesignHeight="480" d:DesignWidth="480">
    
    <UserControl.Resources>

        <LinearGradientBrush x:Key="THCKickerGrayGradientBrush" StartPoint="0,0" EndPoint="0,1">
            <GradientStop Offset="0" Color="Gray"/>
            <GradientStop Offset="4" Color="White"/>
        </LinearGradientBrush>
        
        <system:Double x:Key="THCKickerDefaultFontSize">20</system:Double>
        <system:Double x:Key="THCKickerHistorySmallHeaderFont">20</system:Double>
        <FontFamily x:Key="THCKickerSemiLightFontFamily">PhoneFontFamilySemiLight</FontFamily>
        <FontFamily x:Key="THCKickerHeaderFontFamily">PhoneFontFamilySemiBold</FontFamily>
        
        <Style x:Key="THCKickerTextBlockStyle" TargetType="TextBlock">
            <Setter Property="FontFamily" Value="{StaticResource THCKickerSemiLightFontFamily}" />
            <Setter Property="FontSize" Value="{StaticResource THCKickerDefaultFontSize}"/>
            <Setter Property="TextAlignment" Value="Center"/>
            <Setter Property="VerticalAlignment" Value="Center"/>
            <Setter Property="HorizontalAlignment" Value="Center"/>
            <Setter Property="Foreground" Value="{StaticResource THCKickerGrayGradientBrush}" />
        </Style>

        <Style x:Key="THCKickerSmallHeaderStyle" TargetType="TextBlock" BasedOn="{StaticResource THCKickerTextBlockStyle}">
            <Setter Property="FontSize" Value="{StaticResource THCKickerHistorySmallHeaderFont}" />
            <Setter Property="FontFamily" Value="{StaticResource THCKickerHeaderFontFamily}" />
        </Style>

        <Style x:Key="THCKickerCardStyle" TargetType="Image">
            <Setter Property="HorizontalAlignment" Value="Center" />
            <Setter Property="VerticalAlignment" Value="Center" />
            <Setter Property="Stretch" Value="Fill" />
            <Setter Property="Height" Value="118" />
            <Setter Property="Width" Value="84" />
        </Style>

        <Style x:Key="KickerGridListBoxStyle" TargetType="kickerlb:ListBox">
            <Setter Property="Background" Value="Transparent"/>
            <Setter Property="Foreground" Value="{StaticResource PhoneForegroundBrush}"/>
            <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Disabled"/>
            <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Hidden"/>
            <Setter Property="BorderThickness" Value="0"/>
            <Setter Property="BorderBrush" Value="Transparent"/>
            <Setter Property="Padding" Value="0"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="kickerlb:ListBox">
                        <ContentPresenter>
                            <ItemsPresenter />
                        </ContentPresenter>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
            <Setter Property="HorizontalAlignment" Value="Center"/>
            <Setter Property="VerticalAlignment" Value="Center"/>
        </Style>

        <Style x:Key="KickerNoBorderButton" TargetType="Button">
            <Setter Property="Background" Value="Transparent"/>
            <Setter Property="BorderBrush" Value="{StaticResource PhoneForegroundBrush}"/>
            <Setter Property="Foreground" Value="{StaticResource PhoneForegroundBrush}"/>
            <Setter Property="BorderThickness" Value="{StaticResource PhoneBorderThickness}"/>
            <Setter Property="FontFamily" Value="{StaticResource PhoneFontFamilySemiBold}"/>
            <Setter Property="FontSize" Value="{StaticResource PhoneFontSizeMediumLarge}"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="Button">
                        <Grid Background="Transparent">
                            <VisualStateManager.VisualStateGroups>
                                <VisualStateGroup x:Name="CommonStates">
                                    <VisualState x:Name="Normal"/>
                                    <VisualState x:Name="MouseOver"/>
                                    <VisualState x:Name="Pressed"/>
                                    <VisualState x:Name="Disabled">
                                        <Storyboard>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Foreground" Storyboard.TargetName="ContentContainer">
                                                <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource PhoneDisabledBrush}"/>
                                            </ObjectAnimationUsingKeyFrames>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="BorderBrush" Storyboard.TargetName="ButtonBackground">
                                                <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource PhoneDisabledBrush}"/>
                                            </ObjectAnimationUsingKeyFrames>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Background" Storyboard.TargetName="ButtonBackground">
                                                <DiscreteObjectKeyFrame KeyTime="0" Value="Transparent"/>
                                            </ObjectAnimationUsingKeyFrames>
                                        </Storyboard>
                                    </VisualState>
                                </VisualStateGroup>
                            </VisualStateManager.VisualStateGroups>
                            <Border x:Name="ButtonBackground" 
                                    BorderBrush="{TemplateBinding BorderBrush}" 
                                    Background="{TemplateBinding Background}" 
                                    CornerRadius="0">
                                <ContentControl x:Name="ContentContainer" 
                                                ContentTemplate="{TemplateBinding ContentTemplate}" 
                                                Content="{TemplateBinding Content}" 
                                                Foreground="{TemplateBinding Foreground}" 
                                                HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" 
                                                Padding="{TemplateBinding Padding}" 
                                                VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}" 
                                                Style="{StaticResource ButtonOverlayTemplate}"/>
                            </Border>
                        </Grid>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

        <Style x:Key="THCKickerCardOverlayStyle" TargetType="Button" BasedOn="{StaticResource KickerNoBorderButton}" >
            <Setter Property="HorizontalAlignment" Value="Stretch" />
            <Setter Property="VerticalAlignment" Value="Stretch" />
            <Setter Property="Height" Value="118" />
            <Setter Property="Width" Value="84" />
        </Style>

        <DataTemplate x:Key="KickerGridListBoxItemTemplate">
            <StackPanel Orientation="Vertical" Margin="8,4,8,0">
                <Button Style="{StaticResource THCKickerCardOverlayStyle}" Click="ButtonClick">
                    <Image Source="{Binding CardImage}" Style="{StaticResource THCKickerCardStyle}" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" />    
                </Button>
                <TextBlock Text="{Binding CardName}" Style="{StaticResource THCKickerSmallHeaderStyle}" VerticalAlignment="Center" HorizontalAlignment="Stretch" />
            </StackPanel>
        </DataTemplate>

        <ItemsPanelTemplate x:Key="KickerGridListItemsPanelTemplate">
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition/>
                    <ColumnDefinition/>
                    <ColumnDefinition/>
                    <ColumnDefinition/>
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                    <RowDefinition/>
                    <RowDefinition/>
                    <RowDefinition/>
                    <RowDefinition/>
                </Grid.RowDefinitions>
            </Grid>
        </ItemsPanelTemplate>

    </UserControl.Resources>
    
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition />
            <RowDefinition />
            <RowDefinition />
            <RowDefinition />
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition />
            <ColumnDefinition />
            <ColumnDefinition />
            <ColumnDefinition />
        </Grid.ColumnDefinitions>

        <kickerlb:ListBox x:Name="KickerHoldemListBox" Grid.Row="0" Grid.Column="0"
                       ItemsSource="{Binding}" 
                       Style="{StaticResource KickerGridListBoxStyle}"
                       ItemsPanel="{StaticResource KickerGridListItemsPanelTemplate}"
                       ItemTemplate="{StaticResource KickerGridListBoxItemTemplate}" 
                       Grid.RowSpan="4" Grid.ColumnSpan="4" />
    </Grid>
</UserControl>
